/*
 * @lc app=leetcode.cn id=345 lang=cpp
 *
 * [345] 反转字符串中的元音字母
 */

// @lc code=start
#include <bits/stdc++.h>
using namespace std;
class Solution
{
public:
    inline bool isAlpha(char c)
    {
        return (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U');
    }
    string reverseVowels(string s)
    {
        for (int i = 0, j = s.length() - 1; i < j; ++i, --j)
        {
            while (i < j && !isAlpha(s[i]))
                ++i;
            while(j > i && !isAlpha(s[j]))
                --j;
            swap(s[i], s[j]);
        }
        return s;
    }
};

// int main()
// {
//     cout << Solution().reverseVowels("aA") << endl;
//     return 0;
// }

// @lc code=end
